//
//  SiterOAuthNetManager.m
//  AFNetworking
//
//  Created by Henry on 2023/1/10.
//

#import "SiterOAuthNetManager.h"
#import "SiterAPI.h"

@implementation SiterOAuthNetManager


//注册获取验证码(邮箱)
+ (void) getVerifyCode:(NSString *)email handle:(void(^)(id,NSError *,NSError *)) handler{
 
    NSDictionary *dic = @{@"email":email};
    
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/appGetVerifyCode",[[Siter sharedInstance] getDomain]] parameters:dic completionHandler:^(id responseObj, NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}

//注册账号(邮箱)
+ (void)regist:(NSString *)email withPassword:(NSString *)pasword with:(NSString *)code handle:(void(^)(id,NSError *,NSError *)) handler{
 
    
    NSDictionary *param = @{
                             @"username" :email,
                             @"password": pasword,
                             @"authCode" : code
                             };
    
   [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/appRegister",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}


//修改密码
+ (void)modify:(NSString *)pasword with:(NSString *)code withUsername:(NSString *)username handle:(void(^)(id,NSError *,NSError *)) handler{
    NSDictionary *param = @{
                             @"username":username,
                             @"password": pasword,
                             @"verifyCode" : code
                             };
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/appModifyPswByCode",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}

//重置密码
+ (void)reset:(NSString *)pasword with:(NSString *)code withUsername:(NSString *)username handle:(void(^)(id,NSError *,NSError *)) handler{
    NSDictionary *param = @{
                             @"username":username,
                             @"password": pasword,
                             @"verifyCode" : code
                             };
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/appForgotModifyPswByCode",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}

//验证验证码
+ (void)validateVerifyCode:(NSString *)email with:(NSString *)code handle:(void(^)(id,NSError *,NSError *)) handler{
    NSDictionary *param = @{   @"email" :email,
                             @"verifyCode" : code
                             };
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/validateVerifyCode",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}

//完善账号
+ (void)appRegisterByVisitor:(NSString *)email withAuthCode:(NSString *)code withPassword:(NSString *)password handle:(void(^)(id,NSError *,NSError *)) handler{
    NSDictionary *param = @{   @"username" :email,
                             @"authCode" : code,
                             @"password":password
                             };
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/appRegisterByVisitor",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}


//验证邮箱是否存在
+ (void)validateEmailIsExist:(NSString *)email handle:(void(^)(id,NSError *,NSError *)) handler{
    NSDictionary *param = @{   @"username" :email
                             };
    [self HttpPOSTBYJSON:[NSString stringWithFormat:@"%@/sso/checkUserNameExist",[[Siter sharedInstance] getDomain]] parameters:param completionHandler:^(id responseObj,  NSError *error1, NSError *error2) {
        !handler ?: handler(responseObj, error1,error2);
    }];
}

@end
